<% wrap_layout :layout do %>
  <div class="share">
    <span class="sharemsg">
      <a href="<%= twitter_share_url(current_page.url, i18n.t(data, 'title') + ", " + (i18n.t(data, 'where'))[0].downcase + (i18n.t(data, 'where'))[1..-1] + "" + articles.get(data.page).name) %>">
        <%= i18n.t(data, 'share') %>
      </a></span>

      <span class='st_facebook_large' displayText='Facebook'></span>
      <span class='st_twitter_large' displayText='Tweet'></span>
  </div>
  <div class="theme-choice">
    <label id="theme-label"><%= i18n.t(data, 'selectTheme') %></label>
    <button type="button" aria-labelledby="theme-label" onclick="set_theme('light');"><%= i18n.t(data, 'lightTheme') %></button>
    <button type="button" aria-labelledby="theme-label" onclick="set_theme('dark');"><%= i18n.t(data, 'darkTheme') %></button>
  </div>
  <h1><a href="/"><%= i18n.t(data, 'title') %></a></h2>
  <h2><%= i18n.t(data, 'where') %><%= articles.get(data.page).name %></h2>
  <% if articles.get(data.page).filename %>
    <p class="filelink">
    <%= i18n.t(data, 'getCode')%>
    <a href="/docs/files/<%= articles.get(data.page).filename %>"><%= articles.get(data.page).filename %></a>
    </p>
  <% end %>
  <div id="doc">
    <%= yield %>
    <hr>
    <p><%= i18n.t(data, 'suggestions') % ["https://github.com/adambard/learnxinyminutes-docs/issues/new", "https://github.com/adambard/learnxinyminutes-docs/edit/master/#{current_page.path.split('/', 2)[1]}.markdown"] %>
    </p>
    <p class="contributed">
    <%= i18n.t(data, 'contributor') % [
      articles.get(data.page).contributors[0][0],
      "https://github.com/adambard/learnxinyminutes-docs/blame/master/#{current_page.path.split('/', 2)[1]}.markdown",
      articles.get(data.page).contributor_count] %>
    </p>

    <footer>
    <a style="float: left" rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a>
    <p>
    &copy; <%= Time.now.strftime("%Y") %>
    <% articles.get(data.page).contributors.each_with_index do |author, ii| %>
      <% if author[1] %>
        <a href="<%= author[1] %>"><%= author[0] %></a><%= ',' unless ii >= articles.get(data.page).contributors.length - 1 %>
      <% else %>
        <%= author[0] %><%= ',' unless ii < articles.get(data.page).contributors.length %>
      <% end %>
    <% end %>
    </p>

    <p>
    <% if articles.get(data.page).translators.length > 0 %>
      Translated by:
      <% articles.get(data.page).translators.each do |t| %>
        <a href="<%= t[1] %>"><%= t[0] %></a>
      <% end %>
    <% end %>

    </footer>
  </div>
<% end %>
